package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.dao.AdviceDao;
import com.itheima.pojo.*;
import com.itheima.service.AdviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;


@Service(interfaceClass = AdviceService.class)
@Transactional
public class AdviceServiceImpl implements AdviceService {
    @Autowired
    private AdviceDao adviceDao;


    @Override
    public Plan findByPhone(String phone) {
        Member member = adviceDao.findMember(phone);
        Setmeal setmeal = adviceDao.findByPhone(phone);
        Order order = adviceDao.findOrder(member.getId());
        Plan plan = adviceDao.findBySetmealId(setmeal.getId());
        plan.setImg(setmeal.getImg());
        plan.setMember(member.getName());
        plan.setDate(order.getOrderDate());
        plan.setSetmeal(setmeal.getName());
        return plan;
    }
}
